package com.ruoyi.web.controller.xcx;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.AHousingFollow;
import com.ruoyi.system.domain.vo.AHousingBackXcxVO;
import com.ruoyi.system.domain.vo.HousingFollowVO;
import com.ruoyi.system.domain.vo.PageVO;
import com.ruoyi.system.service.IAHousingFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 我关注房屋信息Controller
 *
 * @author gf
 * @date 2024-11-23
 */
@RestController
@RequestMapping("/xcx/aHousingFollow")
public class XcxAHousingFollow extends BaseController {

    @Autowired
    private IAHousingFollowService aHousingFollowService;

    /**
     * 查询我关注房屋信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(AHousingFollow aHousingFollow) {
        startPage();
        List<AHousingFollow> list = aHousingFollowService.selectAHousingFollowList(aHousingFollow);
        return getDataTable(list);
    }
    /**
     * 统计我关注的房屋
     */
    @GetMapping("/sumNum")
    public AjaxResult sumNum() {
        return success(aHousingFollowService.selectAHousingFollowListSumNum());
    }

    /**
     * 保存我关注的房屋
     */
    @PostMapping("/addHousingFollow")
    public AjaxResult addHousingFollow(@RequestBody AHousingFollow aHousingFollow) {
        return success(aHousingFollowService.selectAHousingFollowListAddHousing(aHousingFollow));
    }

    /***
     * followFlag 返回 关注标识
     * @param aHousingFollow
     * @return
     */
    @GetMapping("/followFlag")
    public AjaxResult followFlag(AHousingFollow aHousingFollow) {
        return success(aHousingFollowService.selectAHousingFollowListFollowFlag(aHousingFollow));
    }

    /***
     * 取消关注数据
     * @param aHousingFollow
     * @return
     */
    @GetMapping("/cancelHousing")
    public AjaxResult cancelHousing(AHousingFollow aHousingFollow) {
        return success(aHousingFollowService.selectAHousingFollowListCancelHousing(aHousingFollow));
    }

    /***
     * 返回关注的数据集合
     * @param vo
     * @return
     */
    @GetMapping("/myFollowList")
    public TableDataInfo myFollowList(HousingFollowVO vo) {
        startPage();
        List<AHousingBackXcxVO> list = aHousingFollowService.selectAHousingFollowFollowList(vo);
        return getDataTable(list);
    }

}
